package com.topscore.uke.mvp.model;

import com.topscore.uke.database.SearchHistoryDAO;
import com.topscore.uke.database.entities.SearchHistoryItem;
import com.topscore.uke.mvp.contractors.SearchHistoryContractor;
import com.topscore.uke.utils.UserInfoManager;

import java.util.List;

/**
 * Created by 71468 on 2018/3/20.
 */

public class SearchHistoryModel implements SearchHistoryContractor, SearchHistoryContractor.Model {
    @Override
    public List<SearchHistoryItem> getHistories() {
        String loginName = UserInfoManager.getUserInfo().getLoginName();
        List<SearchHistoryItem> list = SearchHistoryDAO.getInstance().searchHistories(loginName);
        return list;
    }

    @Override
    public void insertWord(String word) {
        SearchHistoryItem item = new SearchHistoryItem();
        item.setLoginName(UserInfoManager.getUserInfo().getLoginName());
        item.setWord(word);
        SearchHistoryDAO.getInstance().creatOrUpdate(item);

    }
}
